//
//  LoanFeeCell.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/12/17.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class LoanFeeCell: UITableViewCell {
    
    let selectImageView = UIImageView()
    let monthLabel = UILabel() //月份
    let interestLabel = UILabel() //利息
    let supplyLabel = UILabel() //月供

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    
        self.contentView.addSubview(selectImageView)
        
        monthLabel.font = UIFont.boldSystemFont(ofSize: RATIO(maxNum: 16))
        self.contentView.addSubview(monthLabel)
        
        interestLabel.textAlignment = .right
        interestLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 18))
        self.contentView.addSubview(interestLabel)
        
        supplyLabel.textColor = UIColor.gray
        supplyLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.contentView.addSubview(supplyLabel)
        
        let lineView = UIView()
        lineView.backgroundColor = UIColor.lineColor()
        self.contentView.addSubview(lineView)
        
        selectImageView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(RATIO_H(maxNum: 10))
            make.left.equalToSuperview().offset(RATIO(maxNum: 10))
            make.width.height.equalTo(RATIO_H(maxNum: 20))
        }
        
        monthLabel.snp.makeConstraints { (make) in
            make.left.equalTo(selectImageView.snp.right).offset(RATIO(maxNum: 10))
            make.centerY.equalTo(selectImageView)
            make.width.greaterThanOrEqualTo(10)
            make.height.greaterThanOrEqualTo(10)
        }
        
        interestLabel.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(RATIO(maxNum: -10))
            make.centerY.equalTo(monthLabel)
            make.width.greaterThanOrEqualTo(10)
            make.height.greaterThanOrEqualTo(10)
        }
        
        supplyLabel.snp.makeConstraints { (make) in
            make.top.equalTo(interestLabel.snp.bottom).offset(RATIO_H(maxNum: 5))
            make.left.equalTo(interestLabel)
            make.right.equalTo(interestLabel)
            make.height.greaterThanOrEqualTo(10)
        }
        
        lineView.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }
    
    //MARK: 更新样式
    public func updateStyle() {
        
        selectImageView.image = UIImage.init(named: "month_unselect")
        interestLabel.text = "总利息¥0.00元"
        supplyLabel.text = "月供0.00元"
        interestLabel.textColor = UIColor.black
        monthLabel.textColor = UIColor.black
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
